//
//  HRLabelCell.m
//  Hear
//
//  Created by mac on 2017/11/13.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRLabelCell.h"
@interface HRLabelCell ()
@property (nonatomic,strong)UILabel *descLabel;

@end
@implementation HRLabelCell


-(void)setModel:(HRUserLabelModel *)model{
    _model = model;
    self.descLabel.text = model.content;
    self.selectButton.selected = model.isSelect;
}

+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellID = @"HRLabelCell";
    
    HRLabelCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(!cell){
        cell = [[HRLabelCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    if (self)
    {
     
        CGFloat pading = 25;
        
        self.selectButton = [UIButton buttonWithType:0];
        [self.selectButton addTarget:self action:@selector(selectButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.selectButton];
        self.selectButton.frame = CGRectMake(0, 5, 30, 30);
        [self.selectButton setImage:[UIImage imageNamed:@"默认标签"] forState:0];
        [self.selectButton setImage:[UIImage imageNamed:@"选中标签"] forState:UIControlStateSelected];

        self.descLabel = [UILabel new];
        self.descLabel.font = CustomUIFont(15);
        self.descLabel.textColor = SecondTextColor;
        [self  addSubview:self.descLabel];
        self.descLabel.frame = CGRectMake(self.selectButton.right+pading, self.selectButton.top, 100, self.selectButton.height);
        
        
    }
    return self;
}

- (void)selectButtonClick{
    self.model.isSelect = !self.model.isSelect;
    self.selectButton.selected = !self.selectButton.isSelected;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
